package gameEngine;

/**
 * @author Joe R. Nassimian
 * @author Yannis Mazzer
 */
public abstract class BoardGame {
	
	// Variables declaration
	private Board board;
	private static GamesList gamesList = new GamesList();
	private Player[] players;
    // End of variables declaration

	public BoardGame(Settings _gameSettings) {
		board = new Board(_gameSettings.getEdgeSize(), _gameSettings.getBoardsShape());
		players = new Player[_gameSettings.getNbPlayers()];
		for(int i = 0; i < _gameSettings.getNbPlayers(); i++) {
			players[i] = new Player(i+1); 
		}
	}
	
	/**
	 * @param board the board to set
	 */
	public void setBoard(Board _board) {
		this.board = _board;
	}
	
	/**
	 * @return the board
	 */
	public Board getBoard() {
		return board;
	}

	/**
	 * @param players the players to set
	 */
	public void setPlayers(Player[] players) {
		this.players = players;
	}

	/**
	 * @return the players
	 */
	public Player[] getPlayers() {
		return players;
	}
	
	/**
	 * @return the current player
	 */
	public Player getPlayer(int _playerGameIndex) {
		return players[_playerGameIndex-1];
	}
	


	// Static class methods
	/**
	 * @param gamesList the gamesList to set
	 */
	public static void setGamesList(GamesList gamesList) {
		BoardGame.gamesList = gamesList;
	}

	/**
	 * @return the gamesList
	 */
	public static GamesList getGamesList() {
		return gamesList;
	}

	/**
	 * @return the array containing the names of possible games to play
	 */
	public static String[] getGamesNameList() {
		return getGamesList().getGamesArray();
	}
	
	/**
	 * @return the array containing the shapes of the board for a given game.
	 */
	public static String[] getGamesBoardShape(String _name){
		return getGamesList().getBoardShapes(_name);
	}
	
	public static Integer[] getGamesBoardDim(String _name, String _shape){
		return getGamesList().getBoardShapeDimensions(_name, _shape);
	}
	
	public static int getGamesBoardEdgeSize(String _name, String _shape, int _dim){
		return getGamesList().getBoardshapeEdgeSize(_name, _shape, _dim);
	}
	
	public static Integer[] getGamesBoardNbPlayers(String _name, String _shape, int _dim){
		return getGamesList().getBoardShapeNbPlayers(_name, _shape, _dim);
	}

}
